#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

vector<vector<int>> combine(int n, int k) {
    vector<vector<int>> res;
    vector<int> t;
    auto dfs = [&](this auto&& dfs, int u) {
        int d = k - t.size();
        if (d == 0)
        {
            res.push_back(t);
            return;
        }

        for (int i = u + 1; i <= n; i++)
        {
            t.push_back(i);
            dfs(i);
            t.pop_back();
        }
    };

    dfs(0);
    return res;
}

string maximumNumber(string num, vector<int>& change) {
    int l = 0, n = num.size();
    while (l < n && num[l] - '0' >= change[num[l] - '0'])
        l++;
    while (l < n && num[l] - '0' <= change[num[l] - '0'])
    {
        num[l] = change[num[l] - '0'] + '0';
        l++;
    }
    return num;
}